package com.csi.service.impl;

import com.csi.domain.UserAssess;
import com.csi.mapper.AssessMapper;
import com.csi.mapper.UserBookMapper;
import com.csi.service.AssessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
public class AssessServiceImpl implements AssessService {

    @Autowired
    private  AssessMapper assessMapper;

    @Autowired
    private UserBookMapper userBookMapper;
    @Override
    @Transactional
    public int save(UserAssess userAssess) {
        int updated = userBookMapper.updateBook4Access(userAssess.getDueId());
        int saved = assessMapper.save(userAssess);
        return updated + saved;
    }

    /**
     * 查看评价
     * @param hotelId
     * @return
     */
    @Override
    public Map<String,Object> find(long hotelId) {
        return assessMapper.find(hotelId);
    }
}
